package com.ygu.ecare.activity;

import com.ygu.ecare.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ChooseHospital extends Activity {
	private RelativeLayout province = null;
	private TextView area = null;
	private RelativeLayout hospital = null;
	private TextView dq_id = null;
	private TextView yymctext = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.choosehospital);
		province = (RelativeLayout) findViewById(R.id.dq);
		hospital = (RelativeLayout) findViewById(R.id.yy);
		dq_id = (TextView) findViewById(R.id.dq_id);
		area = (TextView) findViewById(R.id.area);
		yymctext = (TextView) findViewById(R.id.yymc);
		setOnClick();
	}
	private void setOnClick(){
		province.setOnClickListener(new OnClickListener() {		
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				//intent.setClass(ChooseHospital.this, ChooseArea.class);
				startActivityForResult(new Intent(ChooseHospital.this, ChooseArea.class), 1);
			}
		});	
		hospital.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(ChooseHospital.this,ChooseYY.class);
				String dqid = dq_id.getText().toString();
				intent.putExtra("dqid", dqid);
				startActivityForResult(intent, 2);
			}
		});
		
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub

		switch(resultCode){
		case 1:
			String cname = data.getExtras().getString("cname");
			String cid = data.getExtras().getString("cid");
			area.setText(cname);	
			dq_id.setText(cid);
			break;
		case 2:
			String yymc = data.getExtras().getString("yymc");
			yymctext.setText(yymc);
			break;
		}
	}
}
